﻿using Framework.SqlSugarCore.Abstractions;
using Framework.SqlSugarCore.Repositories;
using my.abp.Domain.Repositories.User;
using my.abp.Domain.Shared.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;

namespace my.abp.SqlSugarCore.Repositories.User
{
	public class SysUserRoleRepository : SqlSugarRepository<SysUserRole>, ISysUserRoleRepository, ITransientDependency
	{
		public SysUserRoleRepository(ISugarDbContextProvider<ISqlSugarDbContext> sugarDbContextProvider) : base(sugarDbContextProvider)
		{
		}

		/// <summary>
		/// 根据用户Id获取角色Id集合
		/// </summary>
		/// <param name="userId"></param>
		/// <returns></returns>
		public async Task<List<long>> GetUserRoleIdList(long userId)
		{
			return await _DbQueryable.Where(u => u.UserId == userId).Select(u => u.RoleId).ToListAsync();
		}
	}
}
